
import socket

server = socket.socket()

server.bind(('127.0.0.1',8001))
# 127.0.0.1:8001
server.listen()



while 1:

    conn,addr = server.accept()


    from_brower_msg = conn.recv(1024)
    # print(from_brower_msg)
    path = from_brower_msg.decode('utf-8').split(' ')[1]
    print(path)
    conn.send(b'HTTP/1.1 200 ok\r\n\r\n')
    if path == '/':
        with open('04test.html','rb') as f:
            data = f.read()


    elif path == '/style.css':
        with open('style.css', 'rb') as f:
            data = f.read()

    elif path == '/test.js':
        with open('test.js', 'rb') as f:
            data = f.read()

    elif path == '/1.jpg':
        with open('1.jpg', 'rb') as f:
            data = f.read()


    conn.send(data)
    conn.close()










